home *** CD-ROM | disk | FTP | other *** search
/ Amiga Packmags / NewsFlash - Issue 07 (1990-01)(UGA - 17-Bit Software)(Disk 1 of 2)[a intro].zip / NewsFlash - Issue 07 (1990-01)(UGA - 17-Bit Software)(Disk 1 of 2)[a intro].adf / sources / shake.c < prev    next >
C/C++ Source or Header  |  1996-12-24  |  1KB  |  61 lines

  1. /* SHAKE A SCREEN BY CHANGING THE VIEWPORT LEFT/TOP CORNER */
  2. /* NEEDS MATHTRANS LIBRARY */
  3. /* I THINK THE PROGRAM CAN BE COMPILED WITH AZTEC C: */
  4. /* cc shake +l, ln shake.o -lc32 */
  5. /* HAVE FUN, DR, MAYBE */
  6.  
  7. #include <exec/types.h>
  8. #include <graphics/view.h>
  9. #include <intuition/intuitionbase.h>
  10.  
  11. struct IntuitionBase *IntuitionBase;
  12.  
  13. struct alertmessage
  14. {
  15.   SHORT left;
  16.   BYTE top;
  17.   char text[50];
  18.   BYTE flag;
  19. };
  20. struct alertmessage boodschap = 
  21. {
  22.   240,30,"Not today, I am sea sick!",0
  23. };
  24.  
  25. main()
  26. {
  27.   int i,j,OldX,OldY;
  28.   float cos(), sin(), t,s;
  29.  
  30.   if (!(IntuitionBase = (struct IntuitionBase *)
  31.                         OpenLibrary( "intuition.library", 0L) ))
  32.     exit(FALSE);
  33.  
  34.   OldX = IntuitionBase->ActiveScreen->ViewPort.DyOffset;
  35.   OldY = IntuitionBase->ActiveScreen->ViewPort.DyOffset;
  36.  
  37.   s = 0.8;
  38.   while( s >= 0.025 )
  39.   {
  40.     for ( t=0; t<6.3; t+=s)
  41.     {
  42.       i = (int) (32.0*cos(t)+0.5);
  43.       j = (int) (32.0*sin(2.0*t)+0.5);
  44.       do_shift( i,j);
  45.     }
  46.     s -= 0.025;
  47.   }
  48.  
  49.   do_shift( OldX, OldY);
  50.   DisplayAlert( RECOVERY_ALERT, &boodschap, 56);
  51.   CloseLibrary( IntuitionBase);
  52. }
  53.  
  54. do_shift( x, y)
  55. int x,y;
  56. {
  57.   IntuitionBase->ActiveScreen->ViewPort.DyOffset = (SHORT) y;
  58.   IntuitionBase->ActiveScreen->ViewPort.DxOffset = (SHORT) x;
  59.   RemakeDisplay();
  60. }
  61.